<?php


namespace app\common\model;


use think\Model;

class Patent extends Model
{
    protected $autoWriteTimestamp = 'int';
    protected $updateTime = false;

    protected $append = ['inventor_type','receive_type','type','change_type'];

    public function getInventorTypeAttr($value, $data)
    {
        if ($data['inventor_type_id']) {
            $re = PatentInventorType::where('id', $data['inventor_type_id'])->value('name');
            return $re;
        }
    }

    public function getReceiveTypeAttr($value, $data)
    {
        if ($data['receive_type_id']) {
            $re = PatentReceiveType::where('id', $data['receive_type_id'])->value('name');
            return $re;
        }
    }

    public function getTypeAttr($value, $data)
    {
        if ($data['type_id']) {
            $re = PatentType::where('id', $data['type_id'])->value('name');
            return $re;
        }
    }

    public function getChangeTypeAttr($value, $data)
    {
        if ($data['change_type_id']) {
            $re = PatentChangeType::where('id', $data['change_type_id'])->value('name');
            return $re;
        }
    }
}